﻿<Window 
    x:Class="GuidGen.Views.MainWindow"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:Extensions="clr-namespace:GuidGen.Extensions" 
    xmlns:Models="clr-namespace:GuidGen.Models" Title="GuidGen" 
    Height="350" 
    Width="525">

    <Grid
        FocusManager.FocusedElement="{Binding ElementName=btnGen}">

        <Grid.RowDefinitions>
            <RowDefinition Height="Auto"/>
            <RowDefinition/>
        </Grid.RowDefinitions>

        <Grid.ColumnDefinitions>
            <ColumnDefinition/>
            <ColumnDefinition Width="Auto"/>
        </Grid.ColumnDefinitions>

        <TextBox
            FontSize="20"
            Text="{Binding CurrentGuid.Guid, Mode=OneWay}"
            IsReadOnly="True"/>
        <Button
            FontSize="20"
            x:Name="btnGen"
            Grid.Column="1"
            Content="Gen"
            Command="{Binding GenerateGuid}"/>
        <ListBox
            FontSize="20"
            Grid.Row="1"
            Grid.ColumnSpan="2"
            ItemsSource="{Binding LastGuids}"
            Extensions:ControlExtensions.ItemDoubleClickCommand="{Binding ItemDoubleClick}">
            <ListBox.ItemTemplate>
                <DataTemplate DataType="Models:GeneratedGuid">
                    <Grid>
                        <Grid.RowDefinitions>
                            <RowDefinition/>
                            <RowDefinition/>
                        </Grid.RowDefinitions>
                        <TextBlock 
                            Text="{Binding Guid}"/>
                        <TextBlock
                            FontSize="13"
                            Margin="0 5 0 20"
                            FontFamily="Courier New"
                            Grid.Row="1"
                            Text="{Binding GeneratedTime, StringFormat={}{0:dddd d-MMMM-yyyy HH:mm:ss.fff}}"/>
                    </Grid>
                </DataTemplate>
            </ListBox.ItemTemplate>
        </ListBox>
    </Grid>

</Window>